-
-
Notifications
You must be signed in to change notification settings - Fork 33.9k
gh-143674: document complex representation using f/d formats in struct #143879
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
|
This is a documentation-only change; no NEWS entry is needed. Could a triager please add the |
| Complex numbers may also be represented using two consecutive floating-point | ||
| format characters. In this case, the real part is stored first, followed by | ||
| the imaginary part. The format characters ``f`` and ``d`` determine the type | ||
| used for each component. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The are note (10) right below. Much more precise and clear, IMO. What means "may also be"?
Are you used LLM to generate PR? It looks you haven't read the documentation by yourself. Please see this:
Maintainers may close issues and PRs that are not useful or productive, including those that are fully generated by AI. If a contributor repeatedly opens unproductive issues or PRs, they may be blocked.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i have read the documentation myself and have composed it myself only. how about this then?
"Complex numbers are represented (by convention), using two consecutive floating-point format characters. In this case, real part is stored first, and then the imaginary part. the format characters f and d determine the type used for each component"
is this okay?
| @@ -2696,7 +2688,9 @@ these can be preceded by a decimal repeat count:\n\ | |||
| x: pad byte (no data); c:char; b:signed byte; B:unsigned byte;\n\ | |||
| ?: _Bool (requires C99; if not available, char is used instead)\n\ | |||
| h:short; H:unsigned short; i:int; I:unsigned int;\n\ | |||
| l:long; L:unsigned long; f:float; d:double; e:half-float.\n\ | |||
| l:long; L:unsigned long; f:float; d:double; e:half-float.\n\ | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That change is unrelated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah my bad, it is just whitespace error on my side
| For complex numbers, the real and imaginary parts are represented by two\n\ | ||
| consecutive values of the specified floating-point type.\n\ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah my bad. this is my first PR and i am still getting accustomed to contributing to open source. i missed checking for an existing PR on the issue. ill make sure to do that in the future. thanks for the review. i am closing this PR now.
This PR documents the existing convention for representing complex numbers
using scalar floating-point format characters in the struct module.
Specifically, it clarifies that complex numbers may be represented as two
consecutive floating-point values (real part followed by imaginary part),
with the f and d format characters determining the component type.
The clarification is applied consistently to both the runtime docstring
and the library documentation.
📚 Documentation preview 📚: https://cpython-previews--143879.org.readthedocs.build/